package com.zytlifeservice.controller.find;

import com.zytlifeservice.domain.Result;
import com.zytlifeservice.domain.find.ImageText;
import com.zytlifeservice.service.find.ImageTextService;
import com.zytlifeservice.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 图文信息控制类
 * Created by Administrator on 2017/6/2.
 */
@RestController
@RequestMapping(value = "image")
public class ImageTestController {
      @Autowired
      private ImageTextService imageTextService;//图文信息业务类

      @RequestMapping(value = "/get")
      public Result getImageTest(String tname){
          System.out.println("进入单个图文查询");
          ImageText imageText=imageTextService.findOddImageText(tname);
          if(null!=imageText){
              return ResultUtil.success(imageText,"成功");
          }else{
              return ResultUtil.error(-1,"未获取到数据");
          }
      }

      @RequestMapping(value = "/customService")
      public Result findCustomService(){
          System.out.println("进入客服电话方法");
          List<ImageText> imageTextList=new ArrayList<ImageText>();
          ImageText imageText=imageTextService.findOddImageText("平台客服电话");
          ImageText imageText2=imageTextService.findOddImageText("客服QQ");
          ImageText imageText3=imageTextService.findOddImageText("客服微信");
          imageTextList.add(imageText);
          imageTextList.add(imageText2);
          imageTextList.add(imageText3);
          if(null!=imageTextList&&imageTextList.size()>0){
              return ResultUtil.success(imageTextList,"成功");
          }else{
              return ResultUtil.error(-1,"未获取到数据");
          }
      }
}
